package com.cheer.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author cheer
 */
@Getter
@AllArgsConstructor
public enum CaptchaEnum {

    LOGIN(1, "loginCaptcha", "登录验证码"),
    REGISTER(2, "registerCaptcha", "注册验证码"),
    FORGET_PASSWORD(3, "forgetPasswordCaptcha", "忘记密码验证码");

    private final int type;
    private final String attribute;
    private final String description;

    public static String typeToAttribute(int type) {
        for (CaptchaEnum roleEnum : CaptchaEnum.values()) {
            if (Objects.equals(roleEnum.getType(), type)) {
                return roleEnum.attribute;
            }
        }
        return null;
    }
}
